package com.wrong.desgin;

import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author: hliushi
 * @date: 2022/12/5 22:47
 **/
@Slf4j
public class RedisUtils {

    private final Map<String, Object> dataMap = Maps.newConcurrentMap();

    public Object get(String key) {
        log.info(">>> Singleton Redis get data key: {}", key);
        return dataMap.get(key);
    }

    public void set(String key, Object value) {
        log.info(">>> Singleton Redis set data key: {}, value: {}", key, value);
        dataMap.put(key, value);
    }

    public void set(String key, Object value, long timeout, TimeUnit unit) {
        log.info(">>> Singleton Redis set timeout data. time: {} key: {}, value: {}", timeout, key, value);
        dataMap.put(key, value);
    }

    public void del(String key) {
        log.info(">>> Singleton Redis remove data key: {}", key);
        dataMap.remove(key);
    }

}
